<div class="main clearfix">
    <div class="Tabs clearfix">
        <ul class="clearfix">
            <li><a href="<?php echo Url::createUrl("paymentTotal/index")?>"><span>Tổng</span></a></li>
            <li><a href="<?php echo Url::createUrl("paymentSmsWapmaster/index")?>"><span>SMS</span></a></li>
            <li><a href="<?php echo Url::createUrl("paymentCardWapmaster/index")?>"><span>CARD</span></a></li>
            <li><a class="active" href="<?php echo Url::createUrl("paymentChargingWapmaster/index")?>"><span>CHARGING</span></a></li>
        </ul>                
    </div>
    <div class="box_tab bottom30 clearfix">
        <div class="Tabs clearfix">
            <ul class="clearfix">
                <li><a class="active" href="<?php echo Url::createUrl("paymentChargingWapmaster/index")?>"><span>Tài khoản Wapmaster</span></a></li>
                <!--<li><a href="<?php echo Url::createUrl("paymentChargingPartner/index")?>"><span>Nhà phân phối</span></a></li>
                <li><a href="<?php echo Url::createUrl("paymentChargingProduct/index")?>"><span>Sản phẩm</span></a></li>            -->
            </ul>                
        </div>
        <div class="box clearfix">
            <form action="" method="GET">
                <ul class="form4">
                    <li class="clearfix">
                        <label><strong>Từ ngày </strong>:</label>
                        <div class="filltext">
                            <?php
                                $this->widget(
                                    "zii.widgets.jui.CJuiDatePicker"
                                    , array(
                                        "name"=>"toDate"
                                        , "id"=>"toDate"
                                        , "value"=>$search["toDate"]                                                                
                                        , "options"=> array(
                                            'showAnim' => 'fold'
                                            , 'dateFormat' => 'dd-mm-yy'
                                            , 'changeYear' => 'true'
                                            , 'changeMonth' => 'true'
                                            , 'showOn' => 'both'
                                            , 'buttonText' => '<input type="button" name="" value="" class="ic-date">'
                                        )
                                        , 'htmlOptions' => array(
                                            'style' => 'width:170px'
                                            , 'class' => 'form'
                                        )
                                    )
                                );
                            ?>                                       
                            &nbsp;đến ngày &nbsp; 
                            <?php
                                $this->widget(
                                    "zii.widgets.jui.CJuiDatePicker"
                                    , array(
                                        "name"=>"fromDate"
                                        , "id"=>"fromDate"
                                        , "value"=>$search["fromDate"]                                                                
                                        , "options"=> array(
                                            'showAnim' => 'fold'
                                            , 'dateFormat' => 'dd-mm-yy'
                                            , 'changeYear' => 'true'
                                            , 'changeMonth' => 'true'
                                            , 'showOn' => 'both'
                                            , 'buttonText' => '<input type="button" name="" value="" class="ic-date">'
                                        )
                                        , 'htmlOptions' => array(
                                            'style' => 'width:170px'
                                            , 'class' => 'form'
                                        )
                                    )
                                );
                            ?>
                        </div>
                    </li>
                    <li class="clearfix">
                        <label><strong>Từ khóa </strong>:</label>
                        <div class="filltext">
                            <input type="text" id="keyword" name="keyword" style="width:331px;margin-right:28px" value="<?php echo $search["keyword"];?>">
                        </div>
                    </li>
                    <li class="clearfix">
                        <label><strong>Nhà mạng(Telco) </strong>:</label>
                        <div class="filltext">
                            <select style="width:150px;" name="telco">
                                <option value=""> Tất cả </option>                            
                                <option value="1" <?php if($search["telco"]=="1") echo "selected";?> >Viettel</option>                            
                                <option value="2" <?php if($search["telco"]=="2") echo "selected";?> >Mobifone</option>                            
                                <option value="3" <?php if($search["telco"]=="3") echo "selected";?> >Vinaphone</option>                            
                                <option value="4" <?php if($search["telco"]=="4") echo "selected";?> >Vietnammobile</option>                            
                                <option value="5" <?php if($search["telco"]=="5") echo "selected";?> >Beeline</option>                            
                            </select>
                                
                            <select style="width:150px;" name="price">
                                <option value=""> Tất cả </option>
                                <option value="500" <?php if($search["price"]=="500") echo "selected";?> >500</option>
                                <option value="1000" <?php if($search["price"]=="1000") echo "selected";?> >1.000</option>
                                <option value="2000" <?php if($search["price"]=="2000") echo "selected";?> >2.000</option>
                                <option value="3000" <?php if($search["price"]=="3000") echo "selected";?> >3.000</option>
                                <option value="4000" <?php if($search["price"]=="4000") echo "selected";?> >4.000</option>
                                <option value="5000" <?php if($search["price"]=="5000") echo "selected";?> >5.000</option>
                                <option value="10000" <?php if($search["price"]=="10000") echo "selected";?> >10.000</option>
                                <option value="15000" <?php if($search["price"]=="15000") echo "selected";?> >15.000</option>
                            </select>                    
                        </div>
                    </li>
                    <li class="clearfix">
                        <label><strong>Danh mục </strong>:</label>
                        <div class="filltext">
                            <select style="width:150px;" name="content_type">
                                <option value=""> Tất cả </option>                            
                                <?php foreach($content_type as $key=>$value) { ?>
                                <option value="<?php echo $value;?>" <?php if($search["content_type"]==$value) echo "selected";?> ><?php echo $key;?></option>                            
                                <?php } ?>                            
                            </select>
                        </div>
                    </li>
                    <li class="clearfix">
                        <label>&nbsp;</label>
                        <div class="filltext">
                            <input type="submit" value=" Tìm kiếm" class="btn-bigblue"> 
                        </div>
                    </li>

                </ul>
            </form>            
        </div>
    </div>
    
    <div class="box">
        <div class="fillter clearfix">
            <div class="fl">Tìm thấy <strong class="clred"><?php echo $totalUser;?></strong> kết quả trong <strong class="clred"><?php echo $numberPage;?></strong> trang</div>
            <?php                
                $url = new Url();            
                $current_url = Common::getCurrentUrl();
                $path = strpos($current_url,'?') !==false ? $current_url.'&' : $current_url.'?';
                $path = str_replace("?page=".$currentPage."&","?",$path);
                $path = str_replace("&page=".$currentPage."&","&",$path);
            ?>            
            <div class="fr">                
                <ul class="paging">
                    <?php echo Paging::show_paging_cp($numberPage, $currentPage, $path);?>
                </ul>
            </div>
        </div>
        <div class="table clearfix">
            <table width="100%" cellspacing="0" cellpadding="0" border="0">
                <tbody>
                    <tr class="bg-grey">
                        <td width="4%" rowspan="2"><strong>STT</strong></td>
                        <td width="12%" rowspan="2"><strong>Tài khoản </strong></td>
                        <td colspan="9"><strong>Mức phí</strong></td>                        
                        <td width="8%" rowspan="2"><strong>DT sau telco</strong> </td>
                        <td width="8%" rowspan="2"><strong>DT Thành viên (70%)</strong> </td>
                        <td width="8%" rowspan="2"><strong>DT mtop (20%)</strong></td>
                        <td width="8%" rowspan="2"><strong>DT Myzone (10%)</strong></td>
                        <td width="8%" rowspan="2"><strong>Chi tiết</strong></td>
                    </tr>
                    <tr class="bg-grey">
                        <td width="6%"><strong>Tổng</strong></td>
                        <td width="4%"><strong>500</strong></td>
                        <td width="4%"><strong>1.000</strong></td>
                        <td width="4%"><strong>2.000</strong></td>
                        <td width="4%"><strong>3.000</strong></td>
                        <td width="4%"><strong>4.000</strong></td>
                        <td width="4%"><strong>5.000</strong></td>
                        <td width="4%"> <strong>10.000</strong></td>
                        <td width="4%"><strong>15.000</strong></td>
                    </tr>
                    
                    <?php 
                    $total = 0;
                    $total_500 = 0;
                    $total_1000 = 0;
                    $total_2000 = 0;
                    $total_3000 = 0;
                    $total_4000 = 0;
                    $total_5000 = 0;
                    $total_10000 = 0;
                    $total_15000 = 0;
                                        
                    $total_telco = 0;
                    $total_charging = 0;
                    $total_wapmaster = 0;
                    $total_mtop = 0;
                    $total_procuder = 0;
                    
                    $i = 1;
                    foreach($report as $userId=>$row) { 
                        $total += $row["total"];
                        $total_500 += $row["total_500"];
                        $total_1000 += $row["total_1000"];
                        $total_2000 += $row["total_2000"];
                        $total_3000 += $row["total_3000"];
                        $total_4000 += $row["total_4000"];
                        $total_5000 += $row["total_5000"];
                        $total_10000 += $row["total_10000"];
                        $total_15000 += $row["total_15000"];
                        
                        $total_telco += $row["telco"];
                        $total_charging += $row["charging"];
                        $total_wapmaster += $row["wapmaster"];
                        $total_mtop += $row["mtop"];
                        $total_procuder += $row["producer"];
                    ?>
                    <tr>
                        <td><?php echo $i;?></td>
                        <td><a href="#"><strong><?php echo $row["username"];?></strong></a></td>
                        <td><?php echo Common::format_price($row["total"]);?></td>
                        <td><?php echo Common::format_price($row["total_500"]);?></td>                        
                        <td><?php echo Common::format_price($row["total_1000"]);?></td>                        
                        <td><?php echo Common::format_price($row["total_2000"]);?></td>                        
                        <td><?php echo Common::format_price($row["total_3000"]);?></td>                        
                        <td><?php echo Common::format_price($row["total_4000"]);?></td>                        
                        <td><?php echo Common::format_price($row["total_5000"]);?></td>                        
                        <td><?php echo Common::format_price($row["total_10000"]);?></td>                        
                        <td><?php echo Common::format_price($row["total_15000"]);?></td>                        
                        
                        <td class="text-right"><?php echo Common::format_price(round($row["telco"]));?></td>                        
                        <td class="text-right"><?php echo Common::format_price(round($row["wapmaster"]));?></td>
                        <td class="text-right"><?php echo Common::format_price(round($row["mtop"]));?></td>
                        <td class="text-right"><?php echo Common::format_price(round($row["producer"]));?></td>                        
                        <?php
                            $urlDetail = Url::createUrl("paymentChargingWapmaster/detail", array("userId"=>$userId, "keyword"=>$search["keyword"], "toDate"=>$search["toDate"], "fromDate"=>$search["fromDate"], "telco"=>$search["telco"], "price"=>$search["price"], "content_type"=>$search["content_type"]));                            
                        ?>
                        <td>
                            <a href="<?php echo $urlDetail;?>">Chi tiết »</a>
                        </td>
                    </tr>
                    <?php $i++; }?>
                    <tr>
                        <td colspan="2"><strong class="clred">Tổng doanh thu</strong></td>
                        <td><strong class="clred"><?php echo Common::format_price($total);?></strong></td>
                        <td><strong class="clred"><?php echo Common::format_price($total_500);?></strong></td>
                        <td><strong class="clred"><?php echo Common::format_price($total_1000);?></strong></td>
                        <td><strong class="clred"><?php echo Common::format_price($total_2000);?></strong></td>
                        <td><strong class="clred"><?php echo Common::format_price($total_3000);?></strong></td>
                        <td><strong class="clred"><?php echo Common::format_price($total_4000);?></strong></td>
                        <td><strong class="clred"><?php echo Common::format_price($total_5000);?></strong></td>
                        <td><strong class="clred"><?php echo Common::format_price($total_10000);?></strong></td>
                        <td><strong class="clred"><?php echo Common::format_price($total_15000);?></strong></td>
                                                
                        <td class="text-right"><strong class="clred"><?php echo Common::format_price(round($total_telco));?></strong></td>                        
                        <td class="text-right"><strong class="clred"><?php echo Common::format_price(round($total_wapmaster));?></strong></td>
                        <td class="text-right"><strong class="clred"><?php echo Common::format_price(round($total_mtop));?></strong></td>
                        <td class="text-right"><strong class="clred"><?php echo Common::format_price(round($total_procuder));?></strong></td>                        
                    </tr>
                    
                </tbody>
            </table>
        </div>
        <div class="fillter clearfix">
            <div class="fr">
                <ul class="paging">
                    <?php echo Paging::show_paging_cp($numberPage, $currentPage, $path);?>
                </ul>
            </div>
        </div>

    </div>
</div>